package com.briup.jz.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.briup.jz.bean.OrderLine;
import com.briup.jz.bean.OrderLineExample;
import com.briup.jz.dao.OrderLineMapper;
import com.briup.jz.service.IOrderLineService;
import com.briup.jz.utils.CustomerException;


@Service
public class OrderLineServiceImpl  implements IOrderLineService{

	@Autowired
	private OrderLineMapper orderlineMapper;
	
	
	
	@Override
	public void saveOrUpdate(OrderLine orderline) throws CustomerException {
		if(orderline.getId()!=null) {
			orderlineMapper.updateByPrimaryKey(orderline);
		} else {
			
			orderlineMapper.insert(orderline);
		}
	}

	@Override
	public List<OrderLine> query(Long id) {
		OrderLineExample example = new OrderLineExample();
		if(id!=null){
			example.createCriteria().andIdEqualTo(id);
		}
		List<OrderLine> list = orderlineMapper.selectByExample(example);
		return list;
	}

	@Override
	public void deleteById(long id) throws CustomerException {
		OrderLine ordercomment = orderlineMapper.selectByPrimaryKey(id);
		if(ordercomment == null) {
			throw new CustomerException("要删除的分类信息不存在");
	}
		 orderlineMapper.deleteByPrimaryKey(id);
	}
	}
